home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / Watcher / get_col_fld.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-07-13  |  772 b   |  35 lines

  1. /*
  2.    get_col_field: we have a column output format and want a certain
  3.    part of it.  Place the it in 'value' if it exists and return a
  4.    pointer to the string.  If there are problems place a null terminated
  5.    zero length string in 'value' and return NULL as an error condition.
  6.  
  7.    Kenneth Ingham
  8.  
  9.    Copyright (C) 1987 The University of New Mexico
  10. */
  11.  
  12. #include "defs.h"
  13.  
  14. char *
  15. get_col_field(line, start, end, value)
  16. char *line, *value;
  17. int start, end;
  18. {
  19.     int len;
  20.  
  21.     value[0] = '\0';
  22.     len = strlen(line);
  23.  
  24.     /* error checking */
  25.     if (start > len || end > len) {
  26.         fprintf(stderr,"'%s' has %d columns. Specified were %d to %d\n",
  27.             line, len, start, start);
  28.         return NULL;
  29.     }
  30.     len = end - start + 1;
  31.     strncpy(value, &line[start-1], len)[len] = '\0';
  32.  
  33.     return value;
  34. }
  35.